package com.hulizuofang.wol.chat.client.ui.chat;

import java.util.Set;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.inject.Inject;
import com.hulizuofang.wol.chat.client.ui.user.ChatUser;
import com.hulizuofang.wol.chat.client.ui.user.ChatUserPanel;

public class WhoisOnlinePanel extends Composite {
	
	private AbsolutePanel container;
	private VerticalPanel verticalPanel;

	@Inject
	public WhoisOnlinePanel() {
		container = new AbsolutePanel();
		verticalPanel = new VerticalPanel();
	
		container.add(verticalPanel);
		initWidget(container);
	}

	public void refreshOnlineUser(Set<ChatUser> users) {
		verticalPanel.clear();
		if (users != null) for (ChatUser user : users) {
			ChatUserPanel chatUserPanel = new ChatUserPanel(user);
			verticalPanel.add(chatUserPanel);
		}
	}
	
}
